<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>{:C('SERVER_NAME')}</title>
        <link rel="stylesheet" type="text/css" href="__PUBLICADMIN__/css/style.css">
    </head>
    <body>
        <div class="content p50">
            <div class="content-title"><h2>云曝光套餐编辑</h2></div>
            <div class="change">
                <form action="{:U('ExposurePackage/exposurePackageEdit')}" method="post" id="myform">
                    <input type="hidden" name="id" value="{$exposurePackageinfo.id}" >
                    <div class="form-group"><span class="form-title">套餐名：</span>
                        <div class="form-text"><input type="text" id="package_name" value="{$exposurePackageinfo.package_name}" name="package_name"></div>
                    </div>
                    <div class="form-group">
                        <span class="form-title">套餐内容：</span>
                        <div class="combo-box">
                            <div class="combo-add">
                                <span class="form-price">时间：</span>
                                <div  class="form-text"><input type="text" name="exposure_time" value="{$exposurePackageinfo.exposure_time}" id="exposure_time" placeholder="10"></div>
                                <span class="form-price">天</span>
                            </div>
                            <div class="combo-add">
                                <span class="form-price">价格：</span>
                                <div  class="form-text"><input type="text" value="{$exposurePackageinfo.price}"   name="price" id="price" placeholder="10"></div>
                                <span class="form-price">元</span>
                            </div>
                            <div class="combo-add">
                                <span class="form-price">次数：</span>
                                <div  class="form-text"><input type="text" name="exposure_num" value="{$exposurePackageinfo.exposure_num}"  id="exposure_num" placeholder="10"></div>
                                <span class="form-price">次</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <span class="form-title">是否禁用：</span>
                        
                        <span class="form-radio" >否&nbsp; <input type="radio" name="status" <if condition="$exposurePackageinfo['status'] eq 1"  >checked </if>> </span>
                        <span class="form-radio">是&nbsp; <input type="radio" name="status" <if condition="$exposurePackageinfo['status'] eq 0"  >checked </if> ></span>
                    </div>
                    <div class="form-group">
                        <input type="button" name=""   value="提交" class="form-btn btn">
                    </div>
                </form>
            </div>
        </div>
    <include file="Public/ok" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="__PUBLICADMIN__/js/page.js"></script>
    <script>
       
                                    $(function () {
                                        $(".btn").click(function () {
                                            if ($('#package_name').val() == "")
                                            {
                                                prompting("请输入套餐名称");
                                                return false;
                                            } else if ($('#exposure_time').val() == "") {
                                                prompting("请输入时间天数");
                                                return false;
                                            } else if ($('#price').val() == "") {
                                                prompting("请输入价格");
                                                return false;
                                            } else if ($('#exposure_num').val() == "") {
                                                prompting("请输入曝光次数");
                                                return false;
                                            }
                                            
                                            $.ajax({
                                                type: "POST",
                                                url:$("#myform").attr('action') ,
                                                data: $("#myform").serialize(), //表单数据JSON格式的函数参数里填写表单的ID或要提交的表单
                                                dataType: 'json',
                                                success: function (msg) {
                                                        prompting(msg.info);
                                                    if (msg.status == 200) {
                                                        setTimeout(function () {
                                                            window.location.href = "{:U(ExposurePackage/ExposurePackageList)}";
                                                        }, 3000);
                                                    }
                                                },
                                                error: function (error) {
                                                    prompting(error);
                                                }
                                            });
                                        });
                                    });
                                       // ps:注意将同名的放在一个数组里
                function getFormJson(form) {
                    var o = {};
                    var a = $(form).serializeArray();
                    $.each(a, function () {
                    if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                    } else {
                    o[this.name] = this.value || '';
                    }
                    });
                    return o;
                }
    </script>	
</body>
</html>